package com.abel.demo.disruptor;

import com.lmax.disruptor.EventHandler;
import lombok.extern.slf4j.Slf4j;

import java.util.Random;
import java.util.concurrent.TimeUnit;

/**
 * 独立消费者
 */
@Slf4j
public class DisruptorEventIndHandler1 implements EventHandler<DisruptorEvent>{
    private String name;

    public DisruptorEventIndHandler1(String name) {
        this.name = name;
    }

    @Override
    public void onEvent(DisruptorEvent disruptorEvent, long sequence, boolean endOfBatch) throws Exception {
        //模拟事件处理时间
        TimeUnit.MILLISECONDS.sleep(300);

        log.info("独立消费者{}: {},sequence:{},endOfBatch:{}", name, disruptorEvent.getMsg(), sequence, endOfBatch);
    }
}
